//
//  NewsTableViewController.m
//  WY163News
//
//  Created by rong on 15/7/14.
//  Copyright (c) 2015年 rong. All rights reserved.
//

#import "NewsTableViewController.h"
#import "NetWorkTools.h"
#import "News.h"
#import "NewsCell.h"

@interface NewsTableViewController ()

@property (nonatomic, strong) NSArray *newsList;

@end

@implementation NewsTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
   // [News loadNewsListWithURLString:@"T1348647853363/0-20.html" withFinished:];
    
    __weak typeof(self) weakSelf = self;
    [News loadNewsListWithURLString:@"T1348647853363/0-20.html" withFinished:^(NSArray *newsList) {
        
        //给属性赋值
        weakSelf.newsList = newsList;
    }];

}

-(void)setNewsList:(NSArray *)newsList {

    _newsList = newsList;
    
    //设置完数据后，刷新表格
    [self.tableView reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return  self.newsList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    News *new = self.newsList[indexPath.row];
    
    NewsCell *cell = [tableView dequeueReusableCellWithIdentifier:[NewsCell getCellIdentifier:new]forIndexPath:indexPath];
    
    cell.news = self.newsList[indexPath.row];
    
    return cell;
}




@end
